package org.dfzt.modules.online.cgform.enhance.a;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.dfzt.common.system.service.ISysBaseAPI;
import org.dfzt.common.system.vo.SysCategoryModel;
import org.dfzt.common.util.oConvertUtils;
import org.dfzt.modules.online.cgform.enhance.CgformEnhanceJavaListInter;
import org.dfzt.modules.online.cgform.entity.OnlCgformField;
import org.dfzt.modules.online.cgform.service.IOnlCgformFieldService;
import org.dfzt.modules.online.config.exception.BusinessException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;






@Component("cgformEnhanceExportDemo")
public class b
  implements CgformEnhanceJavaListInter
{
  @Autowired
  ISysBaseAPI sysBaseAPI;
  @Autowired
  IOnlCgformFieldService onlCgformFieldService;
  
  public void execute(String tableName, List<Map<String, Object>> data) throws BusinessException {
    List<SysCategoryModel> list = this.sysBaseAPI.queryAllDSysCategory();
    for (Map map : data) {
      
      String str1 = oConvertUtils.getString(map.get("fen_tree"));
      if (oConvertUtils.isEmpty(str1)) {
        continue;
      }
      List list1 = (List)list.stream().filter(paramSysCategoryModel -> paramSysCategoryModel.getId().equals(str1)).collect(Collectors.toList());
      if (list1 != null && list1.size() != 0) {
        map.put("fen_tree", ((SysCategoryModel)list1.get(0)).getName());
      }

      
      String str2 = oConvertUtils.getString(map.get("sel_search"));
      if (oConvertUtils.isEmpty(str2)) {
        continue;
      }
      
      OnlCgformField onlCgformField = this.onlCgformFieldService.queryFormFieldByTableNameAndField(tableName, "sel_search");
      if (onlCgformField == null || oConvertUtils.isEmpty(onlCgformField.getDictTable())) {
        continue;
      }
      List list2 = this.sysBaseAPI.queryTableDictByKeys(onlCgformField.getDictTable(), onlCgformField.getDictText(), onlCgformField.getDictField(), new String[] { str2 });
      if (list2 != null && list2.size() > 0) {
        map.put("sel_search", list2.get(0));
      }
    } 
  }
}
